package com.googlecode.gwtbb.client.only.widget.form;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Jul 24, 2008
 */
public abstract class SingletonFormDialogLink extends FormDialogLink {
	protected SingletonDialogFormStarter formStarter;

	protected SingletonFormDialogLink(String linkText) {
		super(linkText);
		formStarter = new SingletonDialogFormStarter() {
			public void restartForm() {
				SingletonFormDialogLink.this.restartForm();
			}

			public FormWidget createForm() {
				return SingletonFormDialogLink.this.createForm();
			}
		};
	}

	public FormStarter getFormStarter() {
		return formStarter;
	}

	public void clearForm() {
		getForm().reset();
	}

	/**
	 * Hook for subclasses to override
	 */
	public void reinitForm() {
	}

	public void restartForm() {
		clearForm();
		reinitForm();
	}

	public void startProcess() {
		formStarter.startProcess();
	}
}